/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package demo;

import bean.CategoriesBeanRemote;
import bean.OrdersBeanRemote;
import bean.ProductsBeanRemote;
import bean.RolesBeanRemote;
import bean.ShoppingCartRemote;
import bean.UsersBeanRemote;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author HP
 */
public class NewClass {
    OrdersBeanRemote ordersBean = lookupOrdersBeanRemote();
    ShoppingCartRemote shoppingCart = lookupShoppingCartRemote();
    UsersBeanRemote usersBean = lookupUsersBeanRemote();
    RolesBeanRemote rolesBean = lookupRolesBeanRemote();
    ProductsBeanRemote productsBean = lookupProductsBeanRemote();
    CategoriesBeanRemote categoriesBean = lookupCategoriesBeanRemote();

    private CategoriesBeanRemote lookupCategoriesBeanRemote() {
        try {
            Context c = new InitialContext();
            return (CategoriesBeanRemote) c.lookup("java:global/_asm/CategoriesBean!bean.CategoriesBeanRemote");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    private ProductsBeanRemote lookupProductsBeanRemote() {
        try {
            Context c = new InitialContext();
            return (ProductsBeanRemote) c.lookup("java:global/_asm/ProductsBean!bean.ProductsBeanRemote");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    private RolesBeanRemote lookupRolesBeanRemote() {
        try {
            Context c = new InitialContext();
            return (RolesBeanRemote) c.lookup("java:global/_asm/RolesBean!bean.RolesBeanRemote");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    private UsersBeanRemote lookupUsersBeanRemote() {
        try {
            Context c = new InitialContext();
            return (UsersBeanRemote) c.lookup("java:global/_asm/UsersBean!bean.UsersBeanRemote");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    private ShoppingCartRemote lookupShoppingCartRemote() {
        try {
            Context c = new InitialContext();
            return (ShoppingCartRemote) c.lookup("java:global/_asm/ShoppingCart!bean.ShoppingCartRemote");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    private OrdersBeanRemote lookupOrdersBeanRemote() {
        try {
            Context c = new InitialContext();
            return (OrdersBeanRemote) c.lookup("java:global/_asm/OrdersBean!bean.OrdersBeanRemote");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

}
